home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbxsnd11.zip / THEDECK1.BAS < prev    next >
BASIC Source File  |  1991-10-22  |  35KB  |  1,340 lines

  1. DECLARE SUB ButtonSelect (ButtonNumber%, onoff%)
  2. DECLARE SUB ClearButtons (first%, last%)
  3. DECLARE SUB DelayOnPort (times%)
  4. DECLARE SUB DemoInit ()
  5. DECLARE SUB DoHelpInfo ()
  6. DECLARE SUB DoLoadMIDI ()
  7. DECLARE SUB DoLoadVOC ()
  8. DECLARE SUB DoPauseMIDI (onoff%)
  9. DECLARE SUB DoPauseVOC (onoff%)
  10. DECLARE SUB DoPlayMIDI ()
  11. DECLARE SUB DoPlayVoc ()
  12. DECLARE SUB DoRecordVOC ()
  13. DECLARE SUB DoScreenMIDI ()
  14. DECLARE SUB DoStopMIDI ()
  15. DECLARE SUB DoStopVOC ()
  16. DECLARE SUB DrawPanel ()
  17. DECLARE SUB FlashButton ()
  18. DECLARE SUB GetInput (prompt$, answer$)
  19. DECLARE FUNCTION GetKeyPick% (waitfor%)
  20. DECLARE FUNCTION GetMousePick% (MouseButtonState%)
  21. DECLARE SUB MouseFunc (func%, IM AS ANY, OM AS ANY)
  22. DECLARE SUB MouseOnOff (onoff%)
  23. DECLARE FUNCTION SelectEvent% ()
  24. DECLARE SUB SetAutoPlay ()
  25. DECLARE SUB SetColor (fore%, back%)
  26. DECLARE SUB SetLocate (row%, col%)
  27. DECLARE SUB SetPrint (strg$, CR%)
  28. DECLARE SUB SoundEffects (effnumber%)
  29.  
  30. 'in QSND_xx.QLB only
  31. DECLARE SUB INTERRUPTX (intnum%, ireg AS ANY, oreg AS ANY)
  32.  
  33. REM $INCLUDE: 'QBXSOUND.BI'
  34.  
  35. DEFINT A-Z
  36. 'TheDECK (C)1991 Cornel Huth - All Rights Reserved
  37. '22-Oct-91, version 1.03
  38. 'C>bc playdemo /o/e/ah/v
  39.  
  40. '----
  41. TYPE ButtonInfoTYPE
  42. x0 AS INTEGER   'col
  43. y0 AS INTEGER   'row
  44. xs AS INTEGER   'cols
  45. ys AS INTEGER   'rows
  46. END TYPE
  47.  
  48. TYPE RegTYPEx   'interface structure to INTERRUPTX
  49. ax AS INTEGER
  50. bx AS INTEGER
  51. cx AS INTEGER
  52. dx AS INTEGER
  53. bp AS INTEGER
  54. si AS INTEGER
  55. di AS INTEGER
  56. flags AS INTEGER
  57. ds AS INTEGER
  58. es AS INTEGER
  59. END TYPE
  60.  
  61. TYPE MouseTYPE  'interface structure to MOUSEFUNC
  62. ax AS INTEGER
  63. bx AS INTEGER
  64. cx AS INTEGER
  65. dx AS INTEGER
  66. END TYPE
  67.  
  68. TYPE BigChunkTYPE  'for BASIC file I/O
  69. BigChunk AS STRING * 8192
  70. END TYPE
  71. '----
  72.  
  73. CONST MAXBUTTONS = 17
  74.  
  75. DIM SHARED gActiveButton
  76. DIM SHARED gFG          'color tracker
  77. DIM SHARED gBG          'color tracker
  78. DIM SHARED gRow         'row tracker (ni)
  79. DIM SHARED gCol         'col tracker (ni)
  80. DIM SHARED gMouse       '1=use mouse also
  81. DIM SHARED gFMinit      '1=FM capable
  82. DIM SHARED gMIDIinit    '1=MIDI init'ed
  83. DIM SHARED gVOCinit     '1=VOC capable and init'ed
  84. DIM SHARED gMIDIloaded  '1=file loaded
  85. DIM SHARED gVOCloaded   '1=file loaded
  86. DIM SHARED gAutoPlay    '0=single play,1=auto MIDI,2=auto VOC,3=MIDI-VOC-MIDI...
  87. DIM SHARED gNoVU        '1=no VU update of screen (use C>THEDECK /NU)
  88.  
  89. DIM SHARED xreg AS RegTYPEx
  90. DIM SHARED IM AS MouseTYPE
  91. DIM SHARED OM AS MouseTYPE
  92.  
  93. REDIM SHARED gButtonInfo(1 TO MAXBUTTONS) AS ButtonInfoTYPE
  94. REDIM SHARED mbuff(1 TO 1) AS BigChunkTYPE
  95. REDIM SHARED vbuff(1 TO 1) AS BigChunkTYPE
  96.  
  97. DemoInit
  98. DO
  99.    IF xevent >= 0 THEN xevent = SelectEvent
  100.    IF ABS(xevent) = 13 THEN
  101.       xevent = 0
  102.       SELECT CASE gActiveButton
  103.       CASE 1    'eject (load MIDI file)
  104.          DoLoadMIDI
  105.          gMIDIloaded = 1
  106.       CASE 2    'eject (load VOC file)
  107.          DoLoadVOC
  108.          gVOCloaded = 1
  109.       '-----
  110.       CASE 3    'rewind MIDI (restart)
  111.          IF gMIDIloaded THEN SoundEffects 1
  112.          ClearButtons 3, 3
  113.          DoPlayMIDI
  114.          stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  115.          IF stat THEN
  116.             ButtonSelect 4, 1
  117.             gActiveButton = 4
  118.             MIDIpause = 0
  119.             MIDIstarted = 1
  120.          END IF
  121.       CASE 4    'play MIDI
  122.          DoPlayMIDI
  123.          stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  124.          IF stat THEN
  125.             MIDIpause = 0
  126.             MIDIstarted = 1
  127.          END IF
  128.       CASE 5    'FF MIDI
  129.          SoundEffects 2
  130.          ClearButtons 5, 5
  131.          'not implemented
  132.       CASE 6    'stop MIDI
  133.          DoStopMIDI
  134.          MIDIpause = 0
  135.          MIDIstarted = 0
  136.       CASE 7    'pause/cont MIDI
  137.          MIDIpause = NOT MIDIpause
  138.          DoPauseMIDI MIDIpause
  139.       '-----
  140.       CASE 8    'record VOC
  141.          ClearButtons 8, 8
  142.          DoRecordVOC
  143.       CASE 9    'rewind VOC (restart)
  144.          IF gVOCloaded THEN SoundEffects 1
  145.          ClearButtons 9, 9
  146.          DoPlayVoc
  147.          stat = VOCinfo(BT, SR)
  148.          IF stat THEN
  149.             ButtonSelect 10, 1
  150.             gActiveButton = 10
  151.             PauseVOC = 0
  152.             VOCstarted = 1
  153.          END IF
  154.       CASE 10   'play VOC
  155.          DoPlayVoc
  156.          stat = VOCinfo(BT, SR)
  157.          IF stat THEN
  158.             PauseVOC = 0
  159.             VOCstarted = 1
  160.          END IF
  161.       CASE 11   'FF VOC
  162.          SoundEffects 2
  163.          ClearButtons 11, 11
  164.          'not implemented
  165.       CASE 12   'stop VOC
  166.          DoStopVOC
  167.          PauseVOC = 0
  168.          VOCstarted = 0
  169.       CASE 13    'pause/cont VOC
  170.          PauseVOC = NOT PauseVOC
  171.          DoPauseVOC PauseVOC
  172.       CASE 14    'INFO
  173.          DoHelpInfo
  174.       CASE 15    'QUIT
  175.          xevent = 27
  176.       '------
  177.       'if both MIDI and VOC are autoplay then MIDI plays, the VOC, then MIDI...
  178.       CASE 16   'activate auto-play of MIDI
  179.          IF gMIDIloaded THEN
  180.             IF gAutoPlay AND 1 THEN
  181.                gAutoPlay = gAutoPlay AND &HFFFE
  182.             ELSE
  183.                gAutoPlay = gAutoPlay OR 1
  184.             END IF
  185.             SetAutoPlay
  186.          END IF
  187.       CASE 17   'activate auto-play of VOC
  188.          IF gVOCloaded THEN
  189.             IF gAutoPlay AND 2 THEN
  190.                gAutoPlay = gAutoPlay AND &HFFFD
  191.             ELSE
  192.                gAutoPlay = gAutoPlay OR 2
  193.             END IF
  194.             SetAutoPlay
  195.          END IF
  196.       CASE ELSE
  197.       END SELECT
  198.    END IF
  199.  
  200.    IF gMIDIinit THEN
  201.       stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  202.       IF stat THEN
  203.          IF gNoVU = 0 THEN DoScreenMIDI
  204.       ELSEIF MIDIstarted AND VOCstarted = 0 THEN
  205.          MIDIstarted = 0
  206.          xevent = -13
  207.          SELECT CASE gAutoPlay
  208.          CASE 0
  209.             xevent = 0
  210.          CASE 1
  211.             gActiveButton = 4
  212.          CASE 2
  213.             gActiveButton = 10
  214.          CASE 3
  215.             gActiveButton = 10
  216.          CASE ELSE
  217.          END SELECT
  218.       ELSEIF stat = 0 THEN
  219.          MIDIstarted = 0
  220.       END IF
  221.       IF stat = 0 AND gNoVU = 0 THEN DoScreenMIDI
  222.    END IF
  223.  
  224.    IF gVOCinit THEN
  225.       stat = VOCinfo(BT, SR)
  226.       IF stat THEN
  227.          'IF gNoVU = 0 THEN DoScreenVOC
  228.       ELSEIF VOCstarted AND MIDIstarted = 0 THEN
  229.          VOCstarted = 0
  230.          xevent = -13
  231.          SELECT CASE gAutoPlay
  232.          CASE 0
  233.             xevent = 0
  234.          CASE 1
  235.             gActiveButton = 4
  236.          CASE 2
  237.             gActiveButton = 10
  238.          CASE 3
  239.             gActiveButton = 4
  240.          CASE ELSE
  241.          END SELECT
  242.       ELSEIF stat = 0 THEN
  243.          VOCstarted = 0
  244.       END IF
  245.    END IF
  246.  
  247. LOOP UNTIL xevent = 27
  248. MouseOnOff 0
  249.  
  250. ShutDown:
  251. CLOSE
  252. MouseFunc 0, IM, OM
  253. gMouse = 0
  254. LOCATE 25, 1: PRINT SPACE$(80);
  255.  
  256. IF gFMinit THEN
  257.    MusicEnd
  258.    FOR voc = 0 TO 10
  259.       NoteOff voc
  260.    NEXT
  261. END IF
  262.  
  263. IF gVOCinit THEN VOCend
  264.  
  265. LOCATE 1, 1
  266. SELECT CASE ErrCode
  267. CASE 0
  268.    e$ = ""
  269. CASE 7
  270.    e$ = "File too large."
  271. CASE 52, 53, 64, 68, 75, 76
  272.    e$ = "Pathname not found."
  273. CASE 248
  274.    e$ = "SoundBlaster/compatible required for VOC."
  275. CASE 249
  276.    e$ = "AdLib/compatible required for MIDI."
  277. CASE 250
  278.    e$ = "MIDI file has more than single track."
  279. CASE ELSE
  280.    e$ = "BASIC error" + STR$(ErrCode) + ". Program ending."
  281. END SELECT
  282. PRINT e$;
  283. LOCATE 24, 1
  284. END
  285.  
  286. '----
  287. 'disk i/o error handler
  288. 'shut everything down and exit program
  289. DiskHandler:
  290. ErrCode = ERR
  291. RESUME ShutDown
  292.  
  293. '----
  294. 'button x/y positions and x/y size
  295. ButtonInfo:
  296. 'eject
  297. DATA 37,5,3,2
  298. DATA 41,5,3,2
  299. 'MIDI Track
  300. DATA  6,12,4,2
  301. DATA 11,12,6,2
  302. DATA 18,12,4,2
  303. DATA 23,12,6,2
  304. DATA 30,12,5,2
  305. 'VOC Track
  306. DATA 45,12,3,2
  307. DATA 49,12,4,2
  308. DATA 54,12,6,2
  309. DATA 61,12,4,2
  310. DATA 66,12,6,2
  311. DATA 73,12,5,2
  312. 'F1=INFO,ESC=QUIT
  313. DATA 38,17,4,2
  314. DATA 38,21,4,2
  315. 'AUTO
  316. DATA 37,7,3,2
  317. DATA 41,7,3,2
  318.  
  319. SUB ButtonSelect (ButtonNumber, onoff)
  320.  
  321. 'select/deselect button by highlighting/normaling it
  322. 'note x's are column position info, y's are row position info
  323.  
  324. tFG = gFG
  325. tBG = gBG
  326. IF onoff = 0 THEN SetColor 7, 0 ELSE SetColor 15, 0
  327.  
  328. x0 = gButtonInfo(ButtonNumber).x0
  329. y0 = gButtonInfo(ButtonNumber).y0
  330. xs = gButtonInfo(ButtonNumber).xs
  331. ys = gButtonInfo(ButtonNumber).ys
  332. x1 = x0 + xs - 1
  333. y1 = y0 + ys - 1
  334.  
  335. SetLocate y0, x0
  336. SetPrint "┌", 0
  337. FOR i = 1 TO xs - 2
  338.    SetPrint "─", 0
  339. NEXT
  340. SetPrint "┐", 1
  341.  
  342. FOR i = 1 TO ys - 2     'not currently needed since button height=2 (ys)
  343.    SetLocate -1, x0
  344.    SetPrint "│", 0
  345.    SetLocate -1, x1
  346. NEXT
  347.  
  348. SetLocate y1, x0
  349. SetPrint "└", 0
  350. FOR i = 1 TO xs - 2
  351.    SetPrint "─", 0
  352. NEXT
  353. SetPrint "┘", 1
  354.  
  355. SetColor tFG, tBG
  356.  
  357. END SUB
  358.  
  359. SUB ClearButtons (first, last)
  360.  
  361. 'clear buttons
  362.  
  363. FOR i = first TO last
  364.    ButtonSelect i, 0
  365. NEXT
  366.  
  367. END SUB
  368.  
  369. SUB DelayOnPort (times)
  370.  
  371. 'somewhat constant delay by reading through the IO bus
  372. 'times=10000 is about 1 second (50,000 INPs)
  373.  
  374. FOR i = 1 TO times
  375.    nix = INP(&H372)
  376.    nix = INP(&H372)
  377.    nix = INP(&H372)
  378.    nix = INP(&H372)
  379.    nix = INP(&H372)
  380. NEXT
  381.  
  382. END SUB
  383.  
  384. SUB DemoInit
  385.  
  386. CLS
  387. cl$ = COMMAND$
  388. IF INSTR(cl$, "/NU") THEN gNoVU = 1
  389. IF INSTR(cl$, "?") THEN
  390.    PRINT "TheDECK (C)1991 Cornel Huth"
  391.    PRINT
  392.    PRINT "Use C>THEDECK [/NU]"
  393.    PRINT "               /NU for No VU-info"
  394.    PRINT
  395.    PRINT "Press F1 inside program for operating info"
  396.    END
  397. END IF
  398.  
  399. SetColor 7, 0
  400. SetLocate 1, 1
  401.  
  402. gActiveButton = 1
  403.  
  404. 'get button info
  405. RESTORE ButtonInfo
  406. FOR i = 1 TO MAXBUTTONS
  407.    READ x0, y0, xs, ys
  408.    gButtonInfo(i).x0 = x0  'col
  409.    gButtonInfo(i).y0 = y0  'row
  410.    gButtonInfo(i).xs = xs  'cols
  411.    gButtonInfo(i).ys = ys  'rows
  412. NEXT
  413.  
  414. DrawPanel
  415.  
  416. MouseFunc 0, IM, OM: gMouse = OM.ax
  417. IM.cx = 296: IM.dx = 32: MouseFunc 4, IM, OM
  418. MouseOnOff 1
  419. ButtonSelect gActiveButton, 1
  420.  
  421. stat = MusicInit(1)             'start up the MIDI Music Player
  422. IF stat = 0 THEN gFMinit = 1    'FM okay
  423.  
  424. port = -1: irq = -1: DMA = 1
  425. stat = VOCinit(port, irq, DMA)  'test and auto configure SoundBlaster
  426. SetLocate 24, 45
  427. IF stat = 0 THEN
  428.    gVOCinit = 1   'VOC okay
  429.    SetPrint "IO:" + HEX$(port) + " IRQ:" + HEX$(irq), 0
  430. ELSE
  431.    SetPrint "IO:n/a", 0
  432. END IF
  433.  
  434. END SUB
  435.  
  436. SUB DoHelpInfo
  437.  
  438. 'about this program
  439.  
  440. MouseOnOff 0
  441. DoPauseMIDI 1
  442. REDIM sbuff(0 TO 2000)
  443. DEF SEG = &H0: t = PEEK(&H463): DEF SEG
  444. IF t = &HD4 THEN VideoSeg = &HB800 ELSE VideoSeg = &HB000
  445.  
  446. vseg = VARSEG(sbuff(0))
  447. voff = VARPTR(sbuff(0))
  448. FOR i = 0 TO 3999
  449.    DEF SEG = VideoSeg
  450.    vbyte = PEEK(i)
  451.    DEF SEG = vseg
  452.    POKE i, vbyte
  453. NEXT
  454. DEF SEG
  455. DoPauseMIDI 0
  456.  
  457. CLS
  458. PRINT "Press a key or mouse button to RETURN.────── C>THEDECK ? for start info ───────┐";
  459. PRINT "│                00000   To SELECT function use TAB/shift-TAB or Mouse        ∞│";
  460. PRINT "│   ┌─────────────│───────────────┐         ┌──────────────────────────────┐   │";
  461. PRINT "│   │        byte counter         │  EJECT  │                              │   │";
  462. PRINT "│   │                         ┌────>┌─┐ ┌─┐<────┐                          │   │";
  463. PRINT "│   │ Use to load a MIDI file ┘   │ └─┘ └─┘ │   └ Use to load a VOC file   │   │";
  464. PRINT "│   │                             │ ┌─┐ ┌─┐ │                              │   │";
  465. PRINT "│   │                         ┌────>└─┘ └─┘<─┐                             │   │";
  466. PRINT "│   │ Continuous-Auto Play ───┘   │   CAP   │└ either MIDI,VOC,or MIDI+VOC │   │";
  467. PRINT "│   └─────────────────────────────┘         └──────────────────────────────┘   │";
  468. PRINT "│     <<   PLAY   >>   STOP  PAUSE          REC  <<   PLAY   >>   STOP  PAUSE  │";
  469. PRINT "│    ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐          ┌─┐ ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐  │";
  470. PRINT "│∞   └──┘ └────┘ └──┘ └────┘ └───┘          └─┘ └──┘ └────┘ └──┘ └────┘ └───┘ ∞│";
  471. PRINT "│┌──────────────────────────────────┐∞  ∞┌───│────────────────────│────────│──┐│";
  472. PRINT "└┤ │  │  │  │  │  │  │  │  │  │  │  ├────┤   │                    │        │  ├┘";
  473. PRINT " │                                  │INFO│ Record and playback on-│the-spot│  │"
  474. PRINT " │ Each AdLib voice is tracked here │┌──┐│                        │        │  │"
  475. PRINT " │ during the playing of a MIDI file│└──┘│ If the tape 'jams' press STOP   │  │"
  476. PRINT " │                                  │    │                                 │  │"
  477. PRINT " │ The ▓ is the relative volume of  │QUIT│ Pause output anytime (toggled)     │"
  478. PRINT " │ the voice and  is the octave    │┌──┐│                                    │"
  479. PRINT " │                                  │└──┘│ SB configuration is auto-detected  │"
  480. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │ or │      │      │                      │"
  481. PRINT " │∞0  1  2  3  4  5  BD SD TT CY HH∞│ Esc│∞ IO:    IRQ:  (C)1991 Cornel Huth ∞│"
  482. PRINT " └──────────────────────────────────┘    └────────────────────────────────────┘";
  483.  
  484. DO
  485.    kbkey = GetKeyPick(0)
  486.    IF gMouse THEN
  487.       mbkey = GetMousePick(mbstate)
  488.       IF mbstate THEN kbkey = mbstate
  489.    END IF
  490. LOOP UNTIL kbkey
  491.  
  492. DoPauseMIDI 1
  493. vseg = VARSEG(sbuff(0))
  494. voff = VARPTR(sbuff(0))
  495. FOR i = 0 TO 3999
  496.    DEF SEG = vseg
  497.    vbyte = PEEK(i)
  498.    DEF SEG = VideoSeg
  499.    POKE i, vbyte
  500. NEXT
  501. DEF SEG
  502. DoPauseMIDI 0
  503. MouseOnOff 1
  504.  
  505. END SUB
  506.  
  507. SUB DoLoadMIDI
  508.  
  509. 'get MIDI filename
  510. 'load MIDI file into a 64K max buffer, mbuff(1..)
  511.  
  512. ON ERROR GOTO DiskHandler
  513. IF gFMinit = 0 THEN ERROR 249
  514. ON ERROR GOTO 0
  515.  
  516. GetInput "MIDI filename: ", filename$
  517. IF LEN(filename$) = 0 THEN EXIT SUB
  518.  
  519. SetLocate 9, 20
  520. tFG = gFG
  521. tBG = gBG
  522. SetColor 15, 0
  523. SetPrint UCASE$(RIGHT$(filename$ + SPACE$(12 - LEN(RIGHT$(filename$, 12))), 12)), 1
  524. SetColor tFG, tBG
  525.  
  526. ON ERROR GOTO DiskHandler
  527.  
  528. OPEN filename$ FOR INPUT AS #1  'error out before creating a new file
  529. CLOSE #1
  530.  
  531. OPEN filename$ FOR BINARY AS #1
  532. length& = LOF(1)
  533. IF length& > 65520 THEN ERROR 7
  534.  
  535. blocks = (length& \ 8192)
  536. IF length& MOD 8192 THEN blocks = blocks + 1
  537. REDIM mbuff(1 TO blocks) AS BigChunkTYPE
  538.  
  539. ss = 1
  540. DO WHILE NOT EOF(1)
  541.    GET #1, , mbuff(ss).BigChunk
  542.    ss = ss + 1
  543. LOOP
  544. CLOSE #1
  545.  
  546. ON ERROR GOTO 0
  547.  
  548. tapelen = (length& \ 16380) + 1
  549. SetLocate 6, 14
  550. SetPrint STRING$(5, " "), 0
  551. SetLocate 6, 14
  552. SetPrint STRING$(tapelen, ")"), 0
  553. gMIDIinit = 1
  554.  
  555. END SUB
  556.  
  557. SUB DoLoadVOC
  558.  
  559. 'get VOC filename
  560. 'load VOC file into a max buffer, vbuff(1..)
  561.  
  562. ON ERROR GOTO DiskHandler
  563. IF gVOCinit = 0 THEN ERROR 248
  564. ON ERROR GOTO 0
  565.  
  566. GetInput "VOC filename: ", filename$
  567. IF LEN(filename$) = 0 THEN EXIT SUB
  568.  
  569. SetLocate 9, 60
  570. tFG = gFG
  571. tBG = gBG
  572. SetColor 15, 0
  573. SetPrint UCASE$(RIGHT$(filename$ + SPACE$(12 - LEN(filename$)), 12)), 1
  574. SetColor tFG, tBG
  575.  
  576. ON ERROR GOTO DiskHandler
  577.  
  578. OPEN filename$ FOR INPUT AS #1  'error out before creating a new file
  579. CLOSE #1
  580.  
  581. OPEN filename$ FOR BINARY AS #1
  582. length& = LOF(1)
  583. IF length& > 524288 THEN ERROR 7
  584.  
  585. blocks = (length& \ 8192)
  586. IF length& MOD 8192 THEN blocks = blocks + 1
  587. REDIM vbuff(1 TO blocks) AS BigChunkTYPE
  588.  
  589. ss = 1
  590. DO WHILE NOT EOF(1)
  591.    GET #1, , vbuff(ss).BigChunk
  592.    ss = ss + 1
  593. LOOP
  594. CLOSE #1
  595.  
  596. ON ERROR GOTO 0
  597.  
  598. tapelen = (length& \ 65536) + 1
  599. IF tapelen > 5 THEN tapelen = 5
  600. SetLocate 6, 54
  601. SetPrint STRING$(5, " "), 0
  602. SetLocate 6, 54
  603. SetPrint STRING$(tapelen, ")"), 0
  604.  
  605. END SUB
  606.  
  607. SUB DoPauseMIDI (onoff)
  608.  
  609. 'pause/continue playing of the MIDI file
  610.  
  611. IF gMIDIloaded = 0 THEN EXIT SUB
  612.  
  613. IF onoff THEN
  614.    MusicPause
  615. ELSE
  616.    MusicCont
  617. END IF
  618.  
  619. END SUB
  620.  
  621. SUB DoPauseVOC (onoff)
  622.  
  623. 'pause/continue playing of the VOC file
  624.  
  625. IF gVOCloaded = 0 THEN EXIT SUB
  626.  
  627. IF onoff THEN VOCpause ELSE VOCcont
  628.  
  629. END SUB
  630.  
  631. SUB DoPlayMIDI
  632.  
  633. 'play the MIDI file
  634.  
  635. IF gMIDIloaded = 0 THEN EXIT SUB
  636.  
  637. vseg = VARSEG(mbuff(1))
  638. voff = VARPTR(mbuff(1))
  639. stat = MusicPlay(vseg, voff)
  640.  
  641. END SUB
  642.  
  643. SUB DoPlayVoc
  644.  
  645. 'play the VOC file
  646.  
  647. IF gVOCloaded = 0 THEN EXIT SUB
  648.  
  649. stat = VOCinfo(CurrBlockType, CurrSampleRate)
  650. IF stat THEN EXIT SUB   'already active
  651.  
  652. vseg = VARSEG(vbuff(1))
  653. voff = VARPTR(vbuff(1))
  654. stat = VOCplay(vseg, voff)
  655.  
  656. END SUB
  657.  
  658. SUB DoRecordVOC
  659.  
  660. 'get VOC sample rate and seconds to record
  661. 'store VOC data into a max buffer, vbuff(1..)
  662. 'save it? left to the programmer (or use VoxKit)
  663.  
  664. ON ERROR GOTO DiskHandler
  665. IF gVOCinit = 0 THEN ERROR 248
  666. ON ERROR GOTO 0
  667.  
  668. MouseOnOff 0
  669. GetInput "Enter sample rate (5000-11000):", SampleRate$
  670. t& = VAL(SampleRate$)
  671. IF t& < 5000 THEN t& = 5000
  672. IF t& > 11000 THEN t& = 11000
  673. SR = CINT(t&)
  674. maxfre& = FRE(-1) - 64000
  675. maxsecs = maxfre& \ SR
  676. GetInput "Enter seconds to record (1-" + LTRIM$(STR$(maxsecs)) + "):", Second$
  677. t& = VAL(Second$)
  678. IF t& < 1 THEN t& = 1
  679. IF t& > maxsecs THEN t& = maxsecs
  680. rbytes& = t& * SR
  681.  
  682. blocks = (rbytes& \ 8192)
  683. IF rbytes& MOD 8192 THEN blocks = blocks + 1
  684. REDIM vbuff(1 TO blocks) AS BigChunkTYPE
  685.  
  686. GetInput "Press <Enter> to start recording", nix$
  687. vseg = VARSEG(vbuff(1))
  688. voff = VARPTR(vbuff(1))
  689. stat = VOCrecord(SR, rbytes&, vseg, voff)
  690. DO
  691.    stat = VOCinfo(CBT, CSR)
  692. LOOP WHILE stat
  693. GetInput "Press <Enter> to start playback", nix$
  694. stat = VOCplay(vseg, voff)
  695. DO
  696.    stat = VOCinfo(CBT, CSR)
  697. LOOP WHILE stat
  698.  
  699. REDIM vbuff(1 TO 1) AS BigChunkTYPE
  700. MouseOnOff 1
  701.  
  702. END SUB
  703.  
  704. SUB DoScreenMIDI STATIC
  705.  
  706. 'show MIDI info screen
  707.  
  708. DIM lastmode
  709. DIM VolInfo(0 TO 10)
  710. DIM NoteInfo(0 TO 10)
  711.  
  712. IF gMIDIloaded = 0 THEN EXIT SUB
  713.  
  714. stat = MusicInfo(0, note, vol, mode, MusicPtr&)
  715. IF MusicPtr& < 0 THEN MusicPtr& = 0
  716. SetLocate 2, 18
  717. SetPrint RIGHT$("00000" + LTRIM$(STR$(MusicPtr&)), 5), 1
  718.  
  719. IF lastmode <> (mode - 1) THEN
  720.    IF mode = 0 THEN
  721.       maxvoc = 8
  722.       SetLocate 24, 22
  723.       SetPrint "6  7  8       ", 0
  724.       lastmode = -1
  725.    ELSE
  726.       maxvoc = 10
  727.       SetLocate 24, 22
  728.       SetPrint "BD SD TT CY HH", 0
  729.       lastmode = -2
  730.    END IF
  731. END IF
  732.  
  733. ERASE VolInfo
  734. ERASE NoteInfo
  735. FOR voc = 0 TO maxvoc
  736.    stat = MusicInfo(voc, note, vol, mode, MusicPtr&)
  737.    IF vol > 127 THEN vol = 127     'MIDI levels
  738.    IF note > 127 THEN note = 127   ' "     "
  739.    IF stat THEN VolInfo(voc) = (vol + 1) \ 16
  740.    IF stat THEN NoteInfo(voc) = (note + 1) \ 16
  741. NEXT
  742.  
  743. FOR voc = 0 TO maxvoc
  744.    col = 4 + (voc * 3)
  745.    LOCATE 15, col
  746.    FOR i = 1 TO 9
  747.       LOCATE , col
  748.       PRINT "│ "
  749.    NEXT
  750.    LOCATE 23 - VolInfo(voc), col
  751.    IF VolInfo(voc) > 7 THEN COLOR 4, 0 ELSE COLOR 2, 0
  752.    PRINT "▓"
  753.    COLOR 7, 0
  754.    LOCATE 23 - NoteInfo(voc), col + 1
  755.    PRINT ""
  756. NEXT
  757.  
  758. END SUB
  759.  
  760. SUB DoScreenVOC
  761.  
  762. 'nyi
  763.  
  764. END SUB
  765.  
  766. SUB DoStopMIDI
  767.  
  768. 'shut down the MIDI Music Player
  769.  
  770. IF gMIDIinit THEN
  771.    MusicEnd             'shut it down
  772.    nix = MusicInit(1)   'start it back up
  773. END IF
  774.  
  775. END SUB
  776.  
  777. SUB DoStopVOC
  778.  
  779. 'shut down the VOC player
  780.  
  781. IF gVOCinit THEN VOCend
  782.  
  783. END SUB
  784.  
  785. SUB DrawPanel
  786.  
  787. MouseOnOff 0
  788. VIEW PRINT 1 TO 25
  789. CLS
  790.       '123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-
  791. PRINT "┌──────────────────────────────────────────────────────────────────────────────┐";
  792. PRINT "│∞               00000                 ∞                 ......               ∞│";
  793. PRINT "│   ┌─────────────────────────────┐         ┌──────────────────────────────┐   │";
  794. PRINT "│   │                             │  EJECT  │                              │   │";
  795. PRINT "│   │      ┌───────────────┐      │ ┌─┐ ┌─┐ │      ┌────────────────┐      │   │";
  796. PRINT "│   │      │)             (│      │ └─┘ └─┘ │      │)              (│      │   │";
  797. PRINT "│   │      └───────────────┘      │ ┌─┐ ┌─┐ │      └────────────────┘      │   │";
  798. PRINT "│   │                             │ └─┘ └─┘ │                              │   │";
  799. PRINT "│   │  MIDI Track:                │   CAP   │   VOC Track:                 │   │";
  800. PRINT "│   └─────────────────────────────┘         └──────────────────────────────┘   │";
  801. PRINT "│     <<   PLAY   >>   STOP  PAUSE          REC  <<   PLAY   >>   STOP  PAUSE  │";
  802. PRINT "│    ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐          ┌─┐ ┌──┐ ┌────┐ ┌──┐ ┌────┐ ┌───┐  │";
  803. PRINT "│∞   └──┘ └────┘ └──┘ └────┘ └───┘          └─┘ └──┘ └────┘ └──┘ └────┘ └───┘ ∞│";
  804. PRINT "│┌──────────────────────────────────┐∞  ∞┌────────────────────────────────────┐│";
  805. PRINT "└┤ │  │  │  │  │  │  │  │  │  │  │  ├────┤  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  ├┘";
  806. PRINT " │∞│  │  │  │  │  │  │  │  │  │  │ ∞│INFO│∞ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ∞│"
  807. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │┌──┐│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  808. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │└──┘│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  809. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │    │  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  │"
  810. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │QUIT│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  811. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │┌──┐│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  812. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │└──┘│  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  813. PRINT " │ │  │  │  │  │  │  │  │  │  │  │  │    │  ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░  │"
  814. PRINT " │∞0  1  2  3  4  5  6  7  8  .  . ∞│    │∞ IO:    IRQ:  (C)1991 Cornel Huth ∞│"
  815. PRINT " └──────────────────────────────────┘    └────────────────────────────────────┘";
  816.       '123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789-
  817.  
  818. MouseOnOff 1
  819.  
  820. END SUB
  821.  
  822. SUB FlashButton
  823.  
  824. 'flash the active button
  825.  
  826. ButtonSelect gActiveButton, 0
  827. DelayOnPort 500
  828. ButtonSelect gActiveButton, 1
  829. DelayOnPort 500
  830.  
  831. END SUB
  832.  
  833. SUB GetInput (prompt$, answer$)
  834.  
  835. 'get user input from line 1
  836.  
  837. SetLocate 1, 1
  838. SetPrint SPACE$(80), 0
  839. SetLocate 1, 1
  840. SetPrint prompt$, 0
  841. LINE INPUT answer$
  842. SetLocate 1, 1
  843. SetPrint "┌──────────────────────────────────────────────────────────────────────────────┐", 0
  844.  
  845. END SUB
  846.  
  847. FUNCTION GetKeyPick (waitfor)
  848.  
  849. 'get a key, if waitfor then wait until a key
  850.  
  851. DO
  852.    kb$ = INKEY$
  853.    kblen = LEN(kb$)
  854.    SELECT CASE kblen
  855.    CASE 0
  856.      kbkey = 0
  857.    CASE 1
  858.       kbkey = ASC(kb$)
  859.    CASE 2
  860.       kbkey = 1000 + ASC(RIGHT$(kb$, 1))
  861.    CASE ELSE
  862.    END SELECT
  863. LOOP UNTIL kbkey OR (waitfor = 0)
  864. GetKeyPick = kbkey
  865.  
  866. END FUNCTION
  867.  
  868. FUNCTION GetMousePick (MouseButtonState)
  869.  
  870. 'if mouse left button down and cursor is on a event button then
  871. 'set gActiveButton and return 13 else just return 0
  872.  
  873. 'bx=button status
  874. 'cx=horz cursor coor
  875. 'dx=vert cursor coor
  876.  
  877. MouseFunc 3, IM, OM
  878. MouseButtonState = OM.bx
  879.  
  880. match = 0
  881. IF OM.bx = 1 THEN
  882.    mx = OM.cx \ 8
  883.    my = OM.dx \ 8
  884.  
  885.    FOR i = 1 TO MAXBUTTONS
  886.       x0 = gButtonInfo(i).x0 - 1   '0-base it
  887.       y0 = gButtonInfo(i).y0 - 1
  888.       x1 = x0 + gButtonInfo(i).xs - 1
  889.       y1 = y0 + gButtonInfo(i).ys - 1
  890.  
  891.       'check for match in horz and vert positions
  892.  
  893.       IF mx >= x0 AND mx <= x1 THEN
  894.          IF my >= y0 AND my <= y1 THEN
  895.             gActiveButton = i
  896.             match = 13
  897.             EXIT FOR
  898.          END IF
  899.       END IF
  900.    NEXT
  901.  
  902. END IF
  903. GetMousePick = match
  904.  
  905. END FUNCTION
  906.  
  907. SUB MouseFunc (func, IM AS MouseTYPE, OM AS MouseTYPE)
  908.  
  909. 'hey, a complete mouse function routine
  910.  
  911. IF gMouse = 0 AND func > 0 THEN EXIT SUB
  912.  
  913. xreg.es = -1    'IM.ax used to pass ES segment register if needed
  914. SELECT CASE func
  915. CASE 0   'MOUSE RESET AND STATUS
  916.          'set: nothing
  917.          'rtn: ax=status (0=not found/not reset)
  918.          '     bx=buttons
  919.    DEF SEG = 0
  920.    MouseSeg = PEEK(206) + 256 * PEEK(207)
  921.    MouseOff = PEEK(204) + 256 * PEEK(205)
  922.    DEF SEG = MouseSeg
  923.    MouseExists = (MouseSeg <> 0 OR MouseOff <> 0) AND PEEK(MouseOff) <> &HCF
  924.    DEF SEG
  925.    IF MouseExists THEN xreg.ax = 0 ELSE OM.ax = 0: EXIT SUB
  926. CASE 1   'SHOW CURSOR
  927.          'set: nothing
  928.          'rtn: nothing
  929.    xreg.ax = 1
  930. CASE 2   'HIDE CURSOR
  931.          'set: nothing
  932.          'rtn: nothing
  933.    xreg.ax = 2
  934. CASE 3   'GET BUTTON STATUS AND MOUSE POS
  935.          'set: nothing
  936.          'rtn: bx=button status
  937.          '     cx=horz cursor coor
  938.          '     dx=vert cursor coor
  939.    xreg.ax = 3
  940. CASE 4   'SET MOUSE CURSOR POS
  941.          'set: cx=new horz cursor pos
  942.          '     dx=new vert cursor pos
  943.          'rtn: nothing
  944.    xreg.ax = 4
  945.    xreg.cx = IM.cx
  946.    xreg.dx = IM.dx
  947. CASE 5   'GET BUTTON PRESS INFO
  948.          'set: bx=button
  949.          'rtn: ax=button status
  950.          '     bx=number of button presses
  951.          '     cx=horz cursor coor at last press
  952.          '     dx=vert cursor coor at last press
  953.    xreg.ax = 5
  954.    xreg.bx = IM.bx
  955. CASE 6   'GET BUTTON RELEASE INFO
  956.          'set: bx=button
  957.          'rtn: ax=button status
  958.          '     bx=number of button releases
  959.          '     cx=horz cursor coor at last release
  960.          '     dx=vert cursor coor at last release
  961.    xreg.ax = 6
  962.    xreg.bx = IM.bx
  963. CASE 7   'SET MIN AND MAX HORZ CURSOR POS
  964.          'set: cx=min pos
  965.          '     dx=max pos
  966.          'rtn: nothing
  967.    xreg.ax = 7
  968.    xreg.cx = IM.cx
  969.    xreg.dx = IM.dx
  970. CASE 8   'SET MIN AND MAX VERT CURSOR POS
  971.          'set: cx=min pos
  972.          '     dx=max pos
  973.          'rtn: nothing
  974.    xreg.ax = 8
  975.    xreg.cx = IM.cx
  976.    xreg.dx = IM.dx
  977. CASE 9   'SET GRAPHICS CURSOR BLOCK
  978.          'set: ax=segment of cursor mask (NEVER DEFAULT)
  979.          '     bx=horz cursor hot spot
  980.          '     cx=vert cursor hot spot
  981.          '     dx=pointer to screen
  982.          'rtn: nothing
  983.    xreg.ax = 9
  984.    xreg.bx = IM.bx
  985.    xreg.cx = IM.cx
  986.    xreg.dx = IM.dx
  987.    xreg.es = IM.ax
  988. CASE 10  'SET TEXT CURSOR
  989.          'set: bx=cursor select
  990.          '     cx=screen mask value or scan line start
  991.          '     dx=cursor mask value or scan line start
  992.          'rtn: nothing
  993.    xreg.ax = 10
  994.    xreg.bx = IM.bx
  995.    xreg.cx = IM.cx
  996.    xreg.dx = IM.dx
  997. CASE 11  'READ MOUSE MOTION COUNTERS
  998.          'set: nothing
  999.          'rtn: cx=horz mickey count
  1000.          '     dx=vert mickey count
  1001.    xreg.ax = 11
  1002. CASE 12  'SET INTERRUPT SUBROUTINE CALL MASK AND ADDRESS
  1003.          'set: ax=segment of subroutine (NEVER DEFAULT)
  1004.          '     cx=call mask.........bit 0-cursor pos changed
  1005.          '     dx=offset of subroutine '1-left button pressed
  1006.          'rtn: nothing                 '2-left button released
  1007.    xreg.ax = 12                        '3-right button pressed
  1008.    xreg.cx = IM.cx                     '4-right button released
  1009.    xreg.dx = IM.dx                     '5-15 not used
  1010.    xreg.es = IM.ax
  1011. CASE 13  'LIGHT PEN EMULATION MODE ON
  1012.          'set: nothing
  1013.          'rtn: nothing
  1014.    xreg.ax = 13
  1015. CASE 14  'LIGHT PEN EMULATION MODE OFF
  1016.          'set: nothing
  1017.          'rtn: nothing
  1018.    xreg.ax = 14
  1019. CASE 15  'SET MICKEY/PIXEL RATIO
  1020.          'set: cx=horz mickey to pixel ratio
  1021.          '     dx=vert mickey to pixel ratio
  1022.          'rtn: nothing
  1023.    xreg.ax = 15
  1024.    xreg.cx = IM.cx
  1025.    xreg.dx = IM.dx
  1026. CASE 16  'CONDITIONAL OFF
  1027.          'set: ax=left x (slightly different than regular calling registers)
  1028.          '     bx=upper y
  1029.          '     cx=right x
  1030.          '     dx=lower y
  1031.          'rtn: nothing
  1032.    xreg.ax = 16
  1033.    xreg.cx = IM.ax
  1034.    xreg.dx = IM.bx
  1035.    xreg.si = IM.cx
  1036.    xreg.di = IM.dx
  1037. CASE 17, 18
  1038. CASE 19  'SET DOUBLE-SPEED THRESHOLD
  1039.          'set: dx=threshold speed in mickeys/seconds
  1040.          'rtn: nothing
  1041.    xreg.ax = 19
  1042.    xreg.dx = IM.dx
  1043. CASE 20  'SWAP INTERRUPT ROUTINES
  1044.          'set: ax=segment of subroutine (NEVER DEFAULT)
  1045.          '     cx=call mask (as in func 12 above)
  1046.          '     dx=offset of subroutine        ***********************
  1047.          'rtn: bx=segment of old subroutine   *Rtn values valid only*
  1048.          '     cx=call mask of old subroutine *if previous interrupt*
  1049.          '     dx=offset of old subroutine    *was created          *
  1050.    xreg.ax = 20                              '***********************
  1051.    xreg.cx = IM.cx
  1052.    xreg.dx = IM.dx
  1053.    xreg.es = IM.ax
  1054.    INTERRUPTX &H33, xreg, xreg
  1055.    OM.ax = 0
  1056.    OM.bx = xreg.es
  1057.    OM.cx = xreg.cx
  1058.    OM.dx = xreg.dx
  1059.    EXIT SUB
  1060. CASE 21  'GET MOUSE DRIVER STATE STORAGE REQUIREMENTS
  1061.          'set: nothing
  1062.          'rtn: bx=buffer size in bytes
  1063.    xreg.ax = 21
  1064. CASE 22  'SAVE MOUSE DRIVER STATE
  1065.          'set: ax=segment of buffer
  1066.          '     dx=offset of buffer
  1067.          'rtn: nothing
  1068.    xreg.ax = 22
  1069.    xreg.dx = IM.dx
  1070.    xreg.es = IM.ax
  1071. CASE 23  'RESTORE MOUSE DRIVER STATE
  1072.          'set: ax=segment of buffer
  1073.          '     dx=offset of buffer
  1074.          'rtn: nothing
  1075.    xreg.ax = 23
  1076.    xreg.dx = IM.dx
  1077.    xreg.es = IM.ax
  1078. CASE 24  'SET ALTERNATE SUBROUTINE CALL MASK AND ADDRESS
  1079.          'set: ax=segment of user subroutine
  1080.          '     cx=call mask.........bit 0-cursor pos changed
  1081.          '     dx=offset of subroutine '1-left button pressed
  1082.          'rtn: ax=error status (-1)    '2-left button released
  1083.    xreg.ax = 24                        '3-right button pressed
  1084.    xreg.cx = IM.cx                     '4-right button released
  1085.    xreg.dx = IM.dx                     '5-shift key down w/button
  1086.    xreg.es = IM.ax                     '6-ctrl key down w/button
  1087.                                        '7-alt key down w/button
  1088.                                        '8-15 not used
  1089. CASE 25  'GET USER ALTERNATE INTERRUPT ADDRESS
  1090.          'set: cx=user interrupt call mask
  1091.          'rtn: ax=error status (-1)
  1092.          '     bx=segment of user subroutine
  1093.          '     cx=call mask of user interrupt
  1094.          '     dx=offset of subroutine
  1095.    xreg.ax = 25
  1096.    xreg.cx = IM.cx
  1097. CASE 26  'SET MOUSE SENSITIVITY
  1098.          'set: bx=horz mickey sensitivity (0 to 100)  these all
  1099.          '     cx=vert mickey sensitivity (0 to 100)   have default
  1100.          '     dx=threshold for double speed (0 to 100) values=50
  1101.          'rtn: nothing
  1102.    xreg.ax = 26
  1103.    xreg.bx = IM.bx
  1104.    xreg.cx = IM.cx
  1105.    xreg.dx = IM.dx
  1106. CASE 27  'GET MOUSE SENSITIVITY
  1107.          'set: nothing
  1108.          'rtn: bx=horz mickey sensitivity (0 to 100)
  1109.          '     cx=vert mickey sensitivity (0 to 100)
  1110.          '     dx=threshold for double speed (0 to 100)
  1111.    xreg.ax = 27
  1112. CASE 28  'SET MOUSE INTERRUPT RATE (InPort mouse ONLY)
  1113.          'set: bx=rate number (0 (0/sec) to 4 (200/sec))
  1114.          'rtn: nothing
  1115.    xreg.ax = 28
  1116.    xreg.bx = IM.bx
  1117. CASE 29  'SET CRT PAGE NUMBER
  1118.          'set: bx=CRT page for mouse cursor display
  1119.          'rtn: nothing
  1120.    xreg.ax = 29
  1121.    xreg.bx = IM.bx
  1122. CASE 30  'GET CRT PAGE NUMBER
  1123.          'set: nothing
  1124.          'rtn: bx=CRT page for current mouse cursor display
  1125.    xreg.ax = 30
  1126. CASE 31  'DISABLE MOUSE DRIVER
  1127.          'set: nothing
  1128.          'rtn: ax=error status (-1)
  1129.          '     bx=segment of old int 33h
  1130.          '     dx=offset of old int 33h
  1131.    xreg.ax = 31
  1132.    INTERRUPTX &H33, xreg, xreg
  1133.    OM.ax = xreg.ax
  1134.    OM.bx = xreg.es
  1135.    OM.cx = 0
  1136.    OM.dx = xreg.bx
  1137.    EXIT SUB
  1138. CASE 32  'ENABLE MOUSE DRIVER
  1139.          'set: nothing
  1140.          'rtn: nothing
  1141.    xreg.ax = 32
  1142. CASE 33  'SOFTWARE RESET
  1143.          'set: nothing
  1144.          'rtn: ax=-1 (or 33 if mouse drive not installed)
  1145.          '     bx=2 (if ax=-1. Must=2 for a valid reset)
  1146.    xreg.ax = 33
  1147. CASE 34  'SET LANGUAGE FOR MESSAGES (International MOUSE.xxx ONLY)
  1148.          'set: bx=language number
  1149.          'rtn: nothing
  1150.    xreg.ax = 34
  1151.    xreg.bx = IM.bx
  1152. CASE 35  'GET LANGUAGE NUMBER
  1153.          'set: nothing
  1154.          'rtn: bx=language number
  1155.    xreg.ax = 35
  1156. CASE 36  'GET DRIVER VERSION,MOUSE TYPE,AND IRQ NUMBER
  1157.          'set: nothing
  1158.          'rtn: bx=mouse driver version number
  1159.          '        bh=major
  1160.          '        bl=minor
  1161.          '     cx=mouse type and IRQ number
  1162.          '        ch=mouse type (1=bus,2=serial,3=InPort,4=PS/2,5=HP)
  1163.          '        cl=IRQ number (0=PS/2, 2-5 or 7=mouse IRQ)
  1164.    xreg.ax = 36
  1165. CASE ELSE
  1166.    OM.ax = 0
  1167.    OM.bx = 0
  1168.    OM.cx = 0
  1169.    OM.dx = 0
  1170.    EXIT SUB
  1171. END SELECT
  1172.  
  1173. INTERRUPTX &H33, xreg, xreg
  1174. OM.ax = xreg.ax
  1175. OM.bx = xreg.bx
  1176. OM.cx = xreg.cx
  1177. OM.dx = xreg.dx
  1178.  
  1179. END SUB
  1180.  
  1181. SUB MouseOnOff (onoff)
  1182.  
  1183. 'turn the mouse cursor on/off
  1184.  
  1185. IF onoff THEN
  1186.    MouseFunc 1, IM, OM  'show
  1187. ELSE
  1188.    MouseFunc 2, IM, OM  'hide
  1189. END IF
  1190.  
  1191. END SUB
  1192.  
  1193. FUNCTION SelectEvent
  1194.  
  1195. 'determine what's going to happen
  1196.  
  1197. tActiveButton = gActiveButton
  1198.  
  1199. 'read the keyboard for event keys
  1200. '-TABs select active button
  1201. '-ENTER performs active button
  1202. '-mouse supported (left button=select and perform)
  1203.  
  1204. kbkey = GetKeyPick(0)
  1205. IF gMouse THEN
  1206.    mbkey = GetMousePick(mbstate)
  1207.    IF mbkey THEN kbkey = mbkey
  1208. END IF
  1209.  
  1210. SELECT CASE kbkey
  1211. CASE 0
  1212. CASE 9       'TAB->
  1213.    gActiveButton = gActiveButton + 1
  1214.    IF gActiveButton > MAXBUTTONS THEN gActiveButton = 1
  1215. CASE 1015    '<-TAB
  1216.    gActiveButton = gActiveButton - 1
  1217.    IF gActiveButton = 0 THEN gActiveButton = MAXBUTTONS
  1218. CASE 1059    'F1
  1219.    DoHelpInfo
  1220. CASE 13
  1221.    ExitSub = 13
  1222. CASE 27
  1223.    ExitSub = 27
  1224. CASE ELSE
  1225. END SELECT
  1226.  
  1227. IF kbkey THEN
  1228.    ButtonSelect tActiveButton, 0
  1229.    ButtonSelect gActiveButton, 1
  1230.    tActiveButton = gActiveButton
  1231.    IF ExitSub = 13 THEN FlashButton
  1232. END IF
  1233.  
  1234. SelectEvent = ExitSub
  1235.  
  1236. END FUNCTION
  1237.  
  1238. SUB SetAutoPlay
  1239.  
  1240. 'put the appropriate autoplay icons on the panel
  1241.  
  1242. DIM tstr AS STRING * 5
  1243. DIM LA AS STRING * 1
  1244. DIM RA AS STRING * 1
  1245.  
  1246. tstr = " CAP "
  1247. LA = CHR$(17)
  1248. RA = CHR$(16)
  1249.  
  1250. tFG = gFG
  1251. tBG = gBG
  1252. SetColor 15, 0
  1253. SELECT CASE gAutoPlay
  1254. CASE 0
  1255.    SetColor 7, 0
  1256. CASE 1
  1257.    MID$(tstr, 1, 1) = LA
  1258. CASE 2
  1259.    MID$(tstr, 5, 1) = RA
  1260. CASE 3
  1261.    MID$(tstr, 1, 1) = LA
  1262.    MID$(tstr, 5, 1) = RA
  1263. CASE ELSE
  1264. END SELECT
  1265. SetLocate 9, 38
  1266. SetPrint tstr, 0
  1267. SetColor tFG, tBG
  1268.  
  1269. END SUB
  1270.  
  1271. SUB SetColor (fore, back)
  1272.  
  1273. 'all color changes come through here so we can track what's current
  1274.  
  1275. gFG = fore
  1276. gBG = back
  1277. MouseOnOff 0
  1278. COLOR fore, back
  1279. MouseOnOff 1
  1280.  
  1281. END SUB
  1282.  
  1283. SUB SetLocate (row, col)
  1284.  
  1285. 'all locate changes come through here so we can track what's current
  1286.  
  1287. MouseOnOff 0
  1288. IF row > 0 THEN gRow = row
  1289. IF col > 0 THEN gCol = col
  1290. IF row > 0 AND col > 0 THEN
  1291.    LOCATE row, col
  1292. ELSEIF row <= 0 AND col > 0 THEN
  1293.    LOCATE , col
  1294. ELSEIF row > 0 AND col <= 0 THEN
  1295.    LOCATE row
  1296. END IF
  1297. MouseOnOff 1
  1298.  
  1299. END SUB
  1300.  
  1301. SUB SetPrint (strg$, CR)
  1302.  
  1303. 'need to shuffle PRINTs through here so to turn off the mouse cursor
  1304.  
  1305. MouseOnOff 0
  1306. IF CR = 0 THEN PRINT strg$;  ELSE PRINT strg$
  1307. MouseOnOff 1
  1308.  
  1309. END SUB
  1310.  
  1311. SUB SoundEffects (effnumber)
  1312.  
  1313. 'we can interrupt the playing MIDI file and pump out some interesting
  1314. 'sounds (but we have to preserve the FM chip state, easy enough since
  1315. 'there's a built-in QBXSOUND function
  1316. 'just play around with this
  1317.  
  1318. MusicPause
  1319. StateSave
  1320. 'SetSoundMode 0
  1321. InitSlotParms  'w/SoundWarmInit
  1322. SELECT CASE effnumber
  1323. CASE 1  'a very fast rewind
  1324.    FOR note = 75 TO 127
  1325.       NoteOn 0, note
  1326.       DelayOnPort 100
  1327.       NoteOff 0
  1328.    NEXT
  1329. CASE 2  'a high freq
  1330.   NoteOn 0, 127
  1331.   DelayOnPort 1000
  1332.   NoteOff 0
  1333. CASE ELSE
  1334. END SELECT
  1335. StateRestore
  1336. MusicCont
  1337.  
  1338. END SUB
  1339.  
  1340.